package com.amado.course36ByteStream;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class S07DataInputStream {
	public static void main(String[] args) throws IOException {
		FileOutputStream fout = new FileOutputStream("d:/123.txt");
		DataOutputStream dout = new DataOutputStream(fout);
		dout.writeBoolean(true);
		dout.writeChar('A');
		dout.writeInt(111);
		dout.writeBytes("hello World");
		dout.close();

		DataInputStream din = new DataInputStream(new FileInputStream("d:/123.txt"));
		System.out.println(din.readBoolean());
		System.out.println(din.readChar());
		System.out.println(din.readInt());
		byte[] data = new byte[din.available()];
		System.out.println(din.read(data));
		System.out.println(new String(data));
		din.close();
	}

}
